/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.daoimpl;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import model.excecoes.ErroDAOException;
/**
 *
 * @author aluno
 */
public abstract class GenericDAOImpl<Entidade> {
    private EntityManager manager;

    public EntityManager getManager() {
        return manager;
    }

    public void setManager(EntityManager manager) {
        this.manager = manager;
    }
    
    public final void cadastrar(Entidade objeto)throws ErroDAOException, PersistenceException{
        this.manager.getTransaction().begin();
        try{
            this.manager.persist(objeto);
        }catch(PersistenceException ex){
            this.manager.getTransaction().rollback();
            throw new ErroDAOException("Erro ao tentar " + ex.getMessage());
        }
    }
    
    public final void alterar(Entidade objeto)throws ErroDAOException, PersistenceException{
        
    }
    
    public final void excluir(Entidade objeto)throws ErroDAOException, PersistenceException{
        
    }
    
    
            
            
}
